const arr = [
  {id: 4, name: 'ss'},
  {id: 2, name: 'ctx'},
  {id: 3, name: 'zhh'}
]

console.log(arr.sort((a,b) => a.id - b.id))